package com.sline.chario;

import java.io.*;

public class Demo4_Buffered {
    public static void main(String[] args) throws IOException {
        // demo1();

        /*
        * newLine: 写出换行符
        * 和\r\n的区别:
        *   newLine: 是跨平台的方法
        *   \r\n: 只支持windows
        * */
        BufferedReader br = new BufferedReader(new FileReader("abc.txt"));
        BufferedWriter bw = new BufferedWriter(new FileWriter("xxx.txt"));

        String a;
        while ((a = br.readLine()) != null) {
            bw.write(a);
            bw.newLine();
        }

        br.close();
        bw.close();
    }

    private static void demo1() throws IOException {
    /*
    * readLine: 读取文本的一整行, 遇到\r或者\n结束
    * */
        BufferedReader br = new BufferedReader(new FileReader("abc.txt"));

        String line;
        while((line = br.readLine()) != null) {
            System.out.println(line);
        }

        br.close();
    }
}
